#include "Avalon/Codecs/Encoder.hpp"
#include "Avalon/IO/Buffer.hpp"

using namespace Avalon;
using namespace Avalon::Codecs;
using namespace Avalon::IO;

Encoder::~Encoder() {}

Buffer Encoder::Encode(const void* data, int size) {
  Buffer destination;
  Encode(data, size, &destination);
  return destination;
}

Buffer Encoder::Encode(const Buffer& data) {
  return Encode(data.GetData(), data.GetSize());
}

void Encoder::Encode(const Buffer& source, void* destination,
    int destinationSize, int* encodedSize) {
  Encode(source.GetData(), source.GetSize(), destination, destinationSize,
    encodedSize);
}

void Encoder::Encode(const Buffer& source, Buffer* destination,
    int* encodedSize) {
  Encode(source.GetData(), source.GetSize(), destination, encodedSize);
}

void Encoder::EncodeInPlace(void* data, int size, int* encodedSize) {
  Encode(data, size, data, size, encodedSize);
}

void Encoder::EncodeInPlace(Buffer* data, int* encodedSize) {
  EncodeInPlace(data->GetMutableData(), data->GetSize(), encodedSize);
}
